{extend name="public:common_edit" /}

{block name="main"}
<link rel="stylesheet" href="__FONT__/css/font-awesome.min.css" />
<style>
    .modal.in .modal-dialog{
        margin-top: 20%;
        z-index: 10000;
    }
    .modal-backdrop{
        z-index: 0;
    }
    input[type=checkbox], input[type=radio] {
        opacity: 1;
        position: inherit;
        height: 13px;
    }
</style>

<style>
    .modal.in .modal-dialog{
        margin-top: 10%;
        z-index: 10000;
    }
    .modal-backdrop{
        z-index: 0;
    }
</style>
<!--body wrapper start-->
<div class="wrapper">
    <div class="row">
        <div class="col-md-12">
            <!--breadcrumbs start -->
            <ul class="breadcrumb panel">
                <li><a href="{:url('Index/index')}"><i class="fa fa-home"></i> 控制台</a></li>
                <li><a href="{:url('index')}">权限管理</a></li>
                <li class="active">权限管理</li>
            </ul>
            <!--breadcrumbs end -->
        </div>
    </div>

    <ul id="myTab" class="nav nav-tabs">
        <li class="active"><a href="#home" data-toggle="tab">用户组列表</a></li>
        <li><a href="javascript:;" onclick="add()">分配权限</a></li>
    </ul>
    <form action="" method="post"><input type="hidden" name="id" value="{$group_data['id']}">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade in active" id="home">
                <table class="table table-striped table-bordered table-hover table-condensed
	">
                    {foreach $rule_data as $v}
                    {if !$v['_data']}
                    <tr class="b-group">
                        <th width="10%"><label>{$v['title']} <input type="checkbox" name="rule_ids[]" value="{$v['id']}"
                                                                    {in name="$v['id']" value="$group_data['rules']"}
                                                                    checked="checked"
                                                                    {/in}

                            onclick="checkAll(this)" ></label></th>
                        <td></td>
                    </tr>
                    {else}
                    <tr class="b-group">
                        <th width="10%"><label>{$v['title']} <input type="checkbox" name="rule_ids[]" value="{$v['id']}"
                                                                    {in name="$v['id']" value="$group_data['rules']"}
                                                                    checked="checked"
                                                                    {/in}
                            onclick="checkAll(this)"></label></th>
                        <td class="b-child">
                            {foreach $v['_data'] as $n}
                            <table class="table table-striped table-bordered table-hover table-condensed">
                                <tr class="b-group">
                                    <th width="10%"><label>{$n['title']} <input type="checkbox" name="rule_ids[]"
                                                                                value="{$n['id']}"
                                                                                {in name="$n['id']" value="$group_data['rules']"}
                                                                                checked="checked"
                                                                                {/in}
                                        onclick="checkAll(this)"></label></th>
                                    <td>
                                        {if $n['_data']}
                                        {foreach $n['_data'] as $c}<label>&emsp;{$c['title']} <input
                                            type="checkbox" name="rule_ids[]" value="{$c['id']}"
                                            {in name="$c['id']" value="$group_data['rules']"}
                                            checked="checked"
                                            {/in}

                                        ></label>
                                        {/foreach}
                                        {/if}
                                    </td>
                                </tr>
                            </table>
                            {/foreach}
                        </td>
                    </tr>
                    {/if}
                    {/foreach}
                    <tr>
                        <th></th>
                        <td><input class="btn btn-success" type="submit" value="提交"></td>
                    </tr>
                </table>
            </div></div>
    </form>
</div>
<script>
    function checkAll(obj) {
        $(obj).parents('.b-group').eq(0).find("input[type='checkbox']").prop('checked', $(obj).prop('checked'));
    }
</script>
<!--body wrapper end-->
{/block}
